/*     */ package com.yc.dao.station;
/*     */ 
/*     */ import btsm.bean.dbConnector;
/*     */ import com.yc.dao.model.BathunderBO;
/*     */ import com.yc.util.FormateSQL;
/*     */ import com.yc.util.ListContentsBFO;
/*     */ import java.sql.ResultSet;
/*     */ import java.text.SimpleDateFormat;
/*     */ import java.util.ArrayList;
/*     */ import java.util.Date;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ import org.apache.commons.logging.Log;
/*     */ import org.apache.commons.logging.LogFactory;
/*     */ 
/*     */ public class BathunderDAO
/*     */ {
/*  21 */   private static final Log log = LogFactory.getLog(BathunderDAO.class);
/*  22 */   private dbConnector dbcon = null;
/*  23 */   private SimpleDateFormat open = new SimpleDateFormat("yyyy-MM-dd");
/*  24 */   private SimpleDateFormat fresh = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
/*     */ 
/*     */   private void dbConInit() {
/*  27 */     if (this.dbcon == null)
/*  28 */       this.dbcon = new dbConnector();
/*     */   }
/*     */ 
/*     */   private void dbConClose() {
/*  32 */     if (this.dbcon != null)
/*  33 */       this.dbcon.closeAll();
/*  34 */     this.dbcon = null;
/*     */   }
/*     */ 
/*     */   public ListContentsBFO getBathunderList(Map condition)
/*     */   {
/*  40 */     ListContentsBFO bfo = new ListContentsBFO();
/*  41 */     int start = Integer.parseInt(condition.get("start").toString());
/*  42 */     int limit = Integer.parseInt(condition.get("limit").toString());
/*  43 */     String strBtscode = condition.get("BTS_CODE").toString();
/*  44 */     ResultSet rs = null;
/*  45 */     List list = new ArrayList();
/*     */     try
/*     */     {
/*  48 */       dbConInit();
/*  49 */       String strSQL = " select count(id) from bathunder where btscode = '" + strBtscode + "' ";
/*  50 */       log.info(strSQL);
/*  51 */       rs = this.dbcon.execQuery(strSQL);
/*  52 */       if (rs.next()) {
/*  53 */         bfo.setTotalSize(rs.getInt(1));
/*     */       }
/*  55 */       strSQL = " select * from bathunder where btscode ='" + strBtscode + "' limit " + start + ", " + limit;
/*  56 */       log.info(strSQL);
/*  57 */       rs = this.dbcon.execQuery(strSQL);
/*  58 */       while (rs.next()) {
/*  59 */         BathunderBO bo = new BathunderBO();
/*  60 */         bo.setId(rs.getString("id"));
/*  61 */         bo.setBtscode(rs.getString("btscode"));
/*  62 */         bo.setBtsname(rs.getString("btsname"));
/*  63 */         bo.setType(rs.getString("type"));
/*  64 */         bo.setManufacturer(rs.getString("manufacturer"));
/*  65 */         bo.setCapacity(rs.getString("capacity"));
/*  66 */         bo.setNum(rs.getString("num"));
/*  67 */         bo.setOpentime(rs.getDate("registtime"));
/*  68 */         bo.setMaintenance(rs.getString("maintenance"));
/*  69 */         bo.setRefreshtime(rs.getDate("refreshtime"));
/*  70 */         bo.setMemo(rs.getString("memo"));
/*  71 */         bo.setHunderPowerType(rs.getString("hunderPowerType"));
/*  72 */         bo.setHunderWorkSta(rs.getString("hunderWorkSta"));
/*  73 */         bo.setHunderLineLen(rs.getString("hunderLineLen"));
/*     */ 
/*  75 */         list.add(bo);
/*     */       }
/*  77 */       bfo.setData(list.toArray());
/*     */     }
/*     */     catch (Exception e) {
/*  80 */       e.printStackTrace();
/*  81 */       log.error(e.getMessage());
/*     */     }
/*     */     finally {
/*  84 */       dbConClose();
/*     */     }
/*  86 */     return bfo;
/*     */   }
/*     */ 
/*     */   public boolean saveBathunder(BathunderBO bo)
/*     */   {
/*  92 */     log.info("添加--B级防雷器---开始");
/*  93 */     boolean flag = true;
/*     */     try
/*     */     {
/*  96 */       dbConInit();
/*  97 */       StringBuffer sqlBuf = new StringBuffer();
/*  98 */       sqlBuf.append(" insert into bathunder ( btscode,btsname,type,manufacturer,capacity, ");
/*  99 */       sqlBuf.append(" num, registtime,maintenance,refreshtime,memo,hunderPowerType, ");
/* 100 */       sqlBuf.append(" hunderWorkSta, hunderLineLen ) values ( ");
/* 101 */       sqlBuf.append(" '" + bo.getBtscode() + "' ,");
/* 102 */       sqlBuf.append(" '" + bo.getBtsname() + "' ,");
/* 103 */       sqlBuf.append(" '" + bo.getType() + "' ,");
/* 104 */       sqlBuf.append(" '" + bo.getManufacturer() + "' ,");
/* 105 */       sqlBuf.append(" '" + bo.getCapacity() + "' ,");
/* 106 */       sqlBuf.append(" '" + bo.getNum() + "' ,");
/* 107 */       sqlBuf.append(" '" + this.open.format(bo.getOpentime()) + "' ,");
/* 108 */       sqlBuf.append(" '" + bo.getMaintenance() + "' ,");
/* 109 */       sqlBuf.append(" '" + this.fresh.format(new Date()) + "' ,");
/* 110 */       sqlBuf.append(" '" + bo.getMemo() + "' ,");
/* 111 */       sqlBuf.append(" '" + bo.getHunderPowerType() + "' ,");
/* 112 */       sqlBuf.append(" '" + bo.getHunderWorkSta() + "' ,");
/* 113 */       sqlBuf.append(" '" + bo.getHunderLineLen() + "' )");
/* 114 */       log.info(sqlBuf.toString());
/* 115 */       this.dbcon.execUpdate(sqlBuf.toString());
/*     */     }
/*     */     catch (Exception e)
/*     */     {
/* 119 */       flag = false;
/* 120 */       e.printStackTrace();
/* 121 */       log.error(e.getMessage());
/*     */     }
/*     */     finally {
/* 124 */       dbConClose();
/*     */     }
/* 126 */     log.info("添加--B级防雷器---结束");
/* 127 */     return flag;
/*     */   }
/*     */ 
/*     */   public boolean updateBathunder(BathunderBO bo)
/*     */   {
/* 132 */     log.info("修改--B级防雷器---开始");
/* 133 */     boolean flag = true;
/*     */     try
/*     */     {
/* 136 */       dbConInit();
/* 137 */       StringBuffer sqlBuf = new StringBuffer();
/* 138 */       sqlBuf.append(" update bathunder set ");
/* 139 */       sqlBuf.append(" type = '" + bo.getType() + "' ,");
/* 140 */       sqlBuf.append(" manufacturer = '" + bo.getManufacturer() + "' ,");
/* 141 */       sqlBuf.append(" capacity = '" + bo.getCapacity() + "' ,");
/* 142 */       sqlBuf.append(" num = '" + bo.getNum() + "' ,");
/* 143 */       sqlBuf.append(" registtime = '" + this.open.format(bo.getOpentime()) + "' ,");
/* 144 */       sqlBuf.append(" maintenance = '" + bo.getMaintenance() + "' ,");
/* 145 */       sqlBuf.append(" refreshtime = '" + this.fresh.format(new Date()) + "' ,");
/* 146 */       sqlBuf.append(" memo = '" + bo.getMemo() + "' ,");
/* 147 */       sqlBuf.append(" hunderPowerType = '" + bo.getHunderPowerType() + "' ,");
/* 148 */       sqlBuf.append(" hunderWorkSta = '" + bo.getHunderWorkSta() + "' ,");
/* 149 */       sqlBuf.append(" hunderLineLen = '" + bo.getHunderLineLen() + "' ");
/* 150 */       sqlBuf.append(" where id = '" + bo.getId() + "'");
/* 151 */       log.info(sqlBuf.toString());
/* 152 */       this.dbcon.execUpdate(sqlBuf.toString());
/*     */     }
/*     */     catch (Exception e)
/*     */     {
/* 156 */       flag = false;
/* 157 */       e.printStackTrace();
/* 158 */       log.error(e.getMessage());
/*     */     }
/*     */     finally {
/* 161 */       dbConClose();
/*     */     }
/* 163 */     log.info("修改--B级防雷器---结束");
/* 164 */     return flag;
/*     */   }
/*     */ 
/*     */   public boolean deleteBathunder(String strID)
/*     */   {
/* 169 */     log.info("删除--B级防雷器---开始");
/* 170 */     boolean flag = true;
/*     */     try
/*     */     {
/* 173 */       dbConInit();
/* 174 */       StringBuffer sqlBuf = new StringBuffer();
/* 175 */       sqlBuf.append(" delete from bathunder ");
/* 176 */       sqlBuf.append(" where id = '" + strID + "'");
/* 177 */       log.info(sqlBuf.toString());
/* 178 */       this.dbcon.execUpdate(sqlBuf.toString());
/*     */     }
/*     */     catch (Exception e)
/*     */     {
/* 182 */       flag = false;
/* 183 */       e.printStackTrace();
/* 184 */       log.error(e.getMessage());
/*     */     }
/*     */     finally {
/* 187 */       dbConClose();
/*     */     }
/* 189 */     log.info("删除--B级防雷器---结束");
/* 190 */     return flag;
/*     */   }
/*     */ 
/*     */   public ListContentsBFO getBathunderByBtsName(Map condition)
/*     */   {
/* 195 */     ListContentsBFO bfo = new ListContentsBFO();
/* 196 */     int start = Integer.parseInt(condition.get("start").toString());
/* 197 */     int limit = Integer.parseInt(condition.get("limit").toString());
/* 198 */     String strBtsName = condition.get("btsName").toString();
/* 199 */     ResultSet rs = null;
/* 200 */     List list = new ArrayList();
/*     */     try
/*     */     {
/* 203 */       dbConInit();
/* 204 */       Object objRegistBeginTime = condition.get("registBeginTime");
/* 205 */       Object objRegistEndTime = condition.get("registEndTime");
/*     */ 
/* 207 */       String strSQL = " select count(id) from bathunder where ( btsname like '%" + strBtsName + "%' or manufacturer like '%" + strBtsName + "%' )";
/* 208 */       strSQL = FormateSQL.getFormateSQL(objRegistBeginTime, objRegistEndTime, strSQL);
/* 209 */       log.info(strSQL);
/* 210 */       rs = this.dbcon.execQuery(strSQL);
/* 211 */       if (rs.next()) {
/* 212 */         bfo.setTotalSize(rs.getInt(1));
/*     */       }
/* 214 */       strSQL = " select * from bathunder where ( btsname like '%" + strBtsName + "%' or manufacturer like '%" + strBtsName + "%' ) ";
/* 215 */       strSQL = FormateSQL.getFormateSQL(objRegistBeginTime, objRegistEndTime, strSQL);
/* 216 */       strSQL = strSQL + "limit " + start + ", " + limit;
/* 217 */       log.info(strSQL);
/* 218 */       rs = this.dbcon.execQuery(strSQL);
/* 219 */       while (rs.next()) {
/* 220 */         BathunderBO bo = new BathunderBO();
/* 221 */         bo.setId(rs.getString("id"));
/* 222 */         bo.setBtscode(rs.getString("btscode"));
/* 223 */         bo.setBtsname(rs.getString("btsname"));
/* 224 */         bo.setType(rs.getString("type"));
/* 225 */         bo.setManufacturer(rs.getString("manufacturer"));
/* 226 */         bo.setCapacity(rs.getString("capacity"));
/* 227 */         bo.setNum(rs.getString("num"));
/* 228 */         bo.setOpentime(rs.getDate("registtime"));
/* 229 */         bo.setMaintenance(rs.getString("maintenance"));
/* 230 */         bo.setRefreshtime(rs.getDate("refreshtime"));
/* 231 */         bo.setMemo(rs.getString("memo"));
/* 232 */         bo.setHunderPowerType(rs.getString("hunderPowerType"));
/* 233 */         bo.setHunderWorkSta(rs.getString("hunderWorkSta"));
/* 234 */         bo.setHunderLineLen(rs.getString("hunderLineLen"));
/*     */ 
/* 236 */         list.add(bo);
/*     */       }
/* 238 */       bfo.setData(list.toArray());
/*     */     }
/*     */     catch (Exception e) {
/* 241 */       e.printStackTrace();
/* 242 */       log.error(e.getMessage());
/*     */     }
/*     */     finally {
/* 245 */       dbConClose();
/*     */     }
/* 247 */     return bfo;
/*     */   }
/*     */ 
/*     */   public List export(String strBtsName, String strRegistBeginTime, String strRegistEndTime)
/*     */   {
/* 252 */     ResultSet rs = null;
/* 253 */     List list = new ArrayList();
/*     */     try
/*     */     {
/* 256 */       dbConInit();
/* 257 */       String strSQL = " select * from bathunder where ( btsname like '%" + strBtsName + "%' or manufacturer like '%" + strBtsName + "%' ) ";
/* 258 */       strSQL = FormateSQL.getFormateSQL(strRegistBeginTime, strRegistEndTime, strSQL);
/* 259 */       log.info(strSQL);
/* 260 */       rs = this.dbcon.execQuery(strSQL);
/* 261 */       while (rs.next()) {
/* 262 */         BathunderBO bo = new BathunderBO();
/* 263 */         bo.setId(rs.getString("id"));
/* 264 */         bo.setBtscode(rs.getString("btscode"));
/* 265 */         bo.setBtsname(rs.getString("btsname"));
/* 266 */         bo.setType(rs.getString("type"));
/* 267 */         bo.setManufacturer(rs.getString("manufacturer"));
/* 268 */         bo.setCapacity(rs.getString("capacity"));
/* 269 */         bo.setNum(rs.getString("num"));
/* 270 */         bo.setOpentime(rs.getDate("registtime"));
/* 271 */         bo.setMaintenance(rs.getString("maintenance"));
/* 272 */         bo.setRefreshtime(rs.getDate("refreshtime"));
/* 273 */         bo.setMemo(rs.getString("memo"));
/* 274 */         bo.setHunderPowerType(rs.getString("hunderPowerType"));
/* 275 */         bo.setHunderWorkSta(rs.getString("hunderWorkSta"));
/* 276 */         bo.setHunderLineLen(rs.getString("hunderLineLen"));
/*     */ 
/* 278 */         list.add(bo);
/*     */       }
/*     */     }
/*     */     catch (Exception e) {
/* 282 */       e.printStackTrace();
/* 283 */       log.error(e.getMessage());
/*     */     }
/*     */     finally {
/* 286 */       dbConClose();
/*     */     }
/* 288 */     return list;
/*     */   }
/*     */ }

/* Location:           E:\java\apache-tomcat-6.0.36\webapps\btsm\WEB-INF\classes\
 * Qualified Name:     com.yc.dao.station.BathunderDAO
 * JD-Core Version:    0.6.2
 */